load("@fbsource//tools/build_defs:rust_binary.bzl", "rust_binary")
load("@fbsource//tools/build_defs:rust_library.bzl", "rust_library")

oncall("scm_client_infra")

rust_library(
    name = "watchman_client",
    srcs = glob(["src/**/*.rs"]),
    os_deps = [
        (
            "windows",
            ["fbsource//third-party/rust:winapi"],
        ),
    ],
    preferred_linkage = "static",
    deps = [
        "fbsource//third-party/rust:anyhow",
        "fbsource//third-party/rust:bytes",
        "fbsource//third-party/rust:futures",
        "fbsource//third-party/rust:maplit",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:thiserror",
        "fbsource//third-party/rust:tokio",
        "fbsource//third-party/rust:tokio-util",
        "//watchman/rust/serde_bser:serde_bser",
    ],
)

rust_binary(
    name = "state",
    srcs = ["examples/state.rs"],
    link_style = "static",
    deps = [
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:tokio",
        ":watchman_client",
    ],
)

rust_binary(
    name = "glob",
    srcs = ["examples/glob.rs"],
    link_style = "static",
    deps = [
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:serde",
        "fbsource//third-party/rust:tokio",
        ":watchman_client",
    ],
)

rust_binary(
    name = "subscribe",
    srcs = ["examples/subscribe.rs"],
    link_style = "static",
    deps = [
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:tokio",
        ":watchman_client",
    ],
)

rust_binary(
    name = "since",
    srcs = ["examples/since.rs"],
    link_style = "static",
    deps = [
        "fbsource//third-party/rust:clap",
        "fbsource//third-party/rust:tokio",
        ":watchman_client",
    ],
)
